Conditions | 1 |
Paths | 18 |
Total Lines | 56 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 2 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /* |
||
238 | GD.loadPcRedrawValidation = function() { |
||
239 | $('#pca3d_redraw').validate({ |
||
240 | rules: {}, |
||
241 | submitHandler: function(form, event) { |
||
242 | // Manually check if groupa / groupb is empty |
||
243 | if ( $.isEmptyObject( $('select[name="PC3doption1"]').val() ) || $.isEmptyObject( $('select[name="PC3doption2"]').val() ) || $.isEmptyObject( $('select[name="PC3doption3"]').val() ) ) { |
||
244 | $('.select_pc3_validations').text('Please select the Principle components to analyse.'); |
||
245 | return false; |
||
246 | } |
||
247 | // Manually check if PC2dOption1 == PC2dOption2 |
||
248 | if (( $('select[name="PC3doption1"]').val() === $('select[name="PC3doption2"]').val() ) || |
||
249 | ( $('select[name="PC3doption3"]').val() === $('select[name="PC3doption2"]').val() ) || |
||
250 | ( $('select[name="PC3doption1"]').val() === $('select[name="PC3doption3"]').val() ) ) { |
||
251 | $('.select_pc3_validations').text('Please select different principal components to analyse.'); |
||
252 | return false; |
||
253 | } |
||
254 | $('.select_pc3_validations').text(''); |
||
255 | event.preventDefault(); // because we're not submitting at all |
||
256 | $('#principle_plot').empty(); |
||
257 | var x = $('select[name=PC3doption1]').val(); |
||
258 | var y = $('select[name=PC3doption2]').val(); |
||
259 | var z = $('select[name=PC3doption3]').val(); |
||
260 | var jsonFile = $('#overview').data("overview-json"); |
||
261 | $.getJSON(jsonFile, function(json) { |
||
262 | GD.create3dPCAScatterPlot(json.pcdata, x, y, z); |
||
263 | }); |
||
264 | return undefined; |
||
265 | } |
||
266 | }); |
||
267 | $('#pca2d_redraw').validate({ |
||
268 | rules: {}, |
||
269 | submitHandler: function(form, event) { |
||
270 | // Manually check if PC2dOption1 / PC2dOption2 is empty |
||
271 | if ( $.isEmptyObject( $('select[name="PC2doption1"]').val() ) || $.isEmptyObject( $('select[name="PC2doption2"]').val() ) ) { |
||
272 | $('.select_pc2_validations').text('Please select the principal components to analyse.'); |
||
273 | return false; |
||
274 | } |
||
275 | // Manually check if PC2dOption1 == PC2dOption2 |
||
276 | if ( $('select[name="PC2doption1"]').val() === $('select[name="PC2doption2"]').val() ) { |
||
277 | $('.select_pc2_validations').text('Please select different principal components to analyse.'); |
||
278 | return false; |
||
279 | } |
||
280 | |||
281 | $('.select_pc2_validations').text(''); |
||
282 | event.preventDefault(); // because we're not submitting at all |
||
283 | $('#principle_plot').empty(); |
||
284 | var x = $('select[name=PC2doption1]').val(); |
||
285 | var y = $('select[name=PC2doption2]').val(); |
||
286 | var jsonFile = $('#overview').data("overview-json"); |
||
287 | $.getJSON(jsonFile, function(json) { |
||
288 | GD.create2dPCAScatterPlot(json.pcdata, x, y); |
||
289 | }); |
||
290 | return undefined; |
||
291 | } |
||
292 | }); |
||
293 | }; |
||
294 | |||
811 |